package com.ruoyi.ucar.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.ucar.domain.TOrderProductData;
import com.ruoyi.ucar.service.ITOrderProductDataService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单与产品数据关联Controller
 * 
 * @author sungangbin
 * @date 2025-05-13
 */
@RestController
@RequestMapping("/ucar/OrderData")
public class TOrderProductDataController extends BaseController
{
    @Autowired
    private ITOrderProductDataService tOrderProductDataService;

    /**
     * 查询订单与产品数据关联列表
     */
    @PreAuthorize("@ss.hasPermi('ucar:orderData:list')")
    @GetMapping("/list")
    public TableDataInfo list(TOrderProductData tOrderProductData)
    {
        startPage();
        List<TOrderProductData> list = tOrderProductDataService.selectTOrderProductDataList(tOrderProductData);
        return getDataTable(list);
    }

    /**
     * 导出订单与产品数据关联列表
     */
    @PreAuthorize("@ss.hasPermi('ucar:orderData:export')")
    @Log(title = "订单与产品数据关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TOrderProductData tOrderProductData)
    {
        List<TOrderProductData> list = tOrderProductDataService.selectTOrderProductDataList(tOrderProductData);
        ExcelUtil<TOrderProductData> util = new ExcelUtil<TOrderProductData>(TOrderProductData.class);
        util.exportExcel(response, list, "订单与产品数据关联数据");
    }

    /**
     * 获取订单与产品数据关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('ucar:orderData:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tOrderProductDataService.selectTOrderProductDataById(id));
    }

    /**
     * 新增订单与产品数据关联
     */
    @PreAuthorize("@ss.hasPermi('ucar:orderData:add')")
    @Log(title = "订单与产品数据关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TOrderProductData tOrderProductData)
    {
        return toAjax(tOrderProductDataService.insertTOrderProductData(tOrderProductData));
    }

    /**
     * 修改订单与产品数据关联
     */
    @PreAuthorize("@ss.hasPermi('ucar:orderData:edit')")
    @Log(title = "订单与产品数据关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TOrderProductData tOrderProductData)
    {
        return toAjax(tOrderProductDataService.updateTOrderProductData(tOrderProductData));
    }

    /**
     * 删除订单与产品数据关联
     */
    @PreAuthorize("@ss.hasPermi('ucar:orderData:remove')")
    @Log(title = "订单与产品数据关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tOrderProductDataService.deleteTOrderProductDataByIds(ids));
    }
}
